Skip to content

fix(browser-execute): resolve uv to absolute path before spawn#16

Merged
Alezander9 merged 1 commit intomainfrom
fix/uv-locate-windows-path
Apr 28, 2026
Merged

fix(browser-execute): resolve uv to absolute path before spawn#16
Alezander9 merged 1 commit intomainfrom
fix/uv-locate-windows-path

Conversation

@Alezander9
Copy link
Copy Markdown
Member

Problem

On Windows, the uv installer writes %USERPROFILE%\.local\bin into the User PATH registry key. GUI-launched processes (Cursor / VSCode terminal, double-clicked bcode.exe) don't pick up that change until a full re-login. Result: uv --version works in the user's shell but browser_execute spawns uv and gets ENOENT, surfacing as exit 127 with the 'uv is not installed' hint despite uv being installed.

Fix

New packages/bcode-browser/src/uv-locate.ts probes process.env.PATH (with platform-correct extensions on Windows) then a per-platform allowlist of well-known install dirs:

  • Windows: %USERPROFILE%\.local\bin, %LOCALAPPDATA%\uv\bin, %LOCALAPPDATA%\Programs\uv
  • Unix: ~/.local/bin, ~/.cargo/bin, /opt/homebrew/bin, /usr/local/bin

On miss, returns bare "uv" so the existing UV_MISSING_HINT / exit 127 path still fires when uv is genuinely absent.

Memoized via Effect.cached, bound once at make() so the fs probe runs at most once per process.

UV_MISSING_HINT extended with the Windows installer command and a 'restart your terminal' note for the freshly-installed-on-Windows case.

Why this shape

Considered four options:

  1. Resolve to absolute path (this PR) — pure addition, scoped to one spawn site, ENOENT after probe stays honest.
  2. Mutate process.env.PATH at startup — global side effect for one tool's benefit. Rejected.
  3. Bundle our own uv — version drift, install-size hit. Overkill.
  4. Better error only — punts on the actual bug. Rejected.

Pure addition in packages/bcode-browser/. Level 1 per decisions §1c. No upstream diff.

Verification

bun typecheck passes from both packages/bcode-browser and packages/opencode.

End-to-end Windows verification will happen via release artifact after merge — installer command from AGENTS.md tested against a release built from this branch.

Windows users hit ENOENT when uv is installed but %USERPROFILE%\.local\bin
isn't on the bcode process PATH (User-PATH writes by the uv installer aren't
picked up until full re-login by GUI-launched processes).

Probe PATH then a per-platform allowlist; fall back to bare 'uv' so the
existing UV_MISSING_HINT path still fires when uv is genuinely absent.
Memoized via Effect.cached, bound once at make().
Copy link
Copy Markdown

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 2 files

@Alezander9 Alezander9 merged commit f60a8f0 into main Apr 28, 2026
3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant